package org.yuanzheng.savepoint

import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}

/**
 * @author yuanzheng
 * @date 2020/6/21-16:14
 */
object TestSavePoint {
  def main(args: Array[String]): Unit = {
    val streamEnv: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
    streamEnv.setParallelism(1) //设置所有算子的并行度为1
    val stream: DataStream[String] = streamEnv.socketTextStream("192.168.1.8", 8888)
    import org.apache.flink.streaming.api.scala._
    val result: DataStream[(String, Int)] = stream.flatMap(_.split(" ")).uid("flatmap001")
      .map((_, 1))
      .setParallelism(2).uid("map001")
      .keyBy(0)
      .sum(1).uid("sum001")
    result.print().setParallelism(1)
    streamEnv.execute("wordCount")
  }
}
